﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using S4Store.Domain.Report;
using S4Store.Domain;

namespace S4Store.Models.SellerKpi
{
    public class CarKpiPersonBodyModel
    {
        public CarKpiPersonBodyModel()
        {
            Reports = new List<CarModelSaleReport>();
        }

        public List<CarModelSaleReport> Reports { get; set; }

        public List<CarBrand> CarBrands
        {
            get
            {
                return Reports.GroupBy(t => t.CarModel.Brand).Select(t => t.Key).ToList(); 
            }
        }

        public List<CarModel> GetCarModels(CarBrand brand)
        {
            return Reports.Where(t => t.CarModel.Brand.Id == brand.Id).GroupBy(t => t.CarModel).Select(t => t.Key).ToList();       
        }

        public CarModelSaleReport GetReportByCarModel(CarModel carmodel)
        {
            var model = Reports.FirstOrDefault(t => t.CarModel.Id == carmodel.Id);
            if (model == null)
            {
                model = new CarModelSaleReport();
            }
            return model;
        }

    }
}